<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;

$this->title = Yii::t('app', 'Order Price Types');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="order-price-type-index">
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p class="pull-right">
        <?= Html::a(Yii::t('app', 'Create Order Price Type'), ['create', 'product_id'=>$product_id], ['class' => 'btn btn-success']) ?>
    </p>
	<?php Pjax::begin(); ?>    
		<?= GridView::widget([
	        'dataProvider' => $dataProvider,
	        'filterModel' => $searchModel,
	        'columns' => [
	            ['class' => 'yii\grid\SerialColumn'],
	
	            //'id',
	            //'product_id',
	            'name',
	            'price',
	            'desc',
	            //'status',
	            [
	                'attribute' => 'status',
	                'filter' => Yii::$app->params['status'],
	                'value' => function ($model) {
	                    return Yii::$app->params['status'][$model->status];
	                },
            	],
	            
	            // 'user_id',
	             'created_at',
	            // 'updated_at',
	             //'type',
	             [
	                'attribute' => 'type',
	                'filter' => Yii::$app->params['order_price_type'],
	                'value' => function ($model) {
	                    return Yii::$app->params['order_price_type'][$model->type];
	                },
            	],
	            [
	                'label'=>'人数统计',
	                'format'=>'raw',
	                'value' => function($model){
						$a = Html::a('详情','/order/type/nums?id='.$model->id, ['data-toggle'=>'modal', 'data-target'=>'.nums-modal']);
						$nums = $model->customerNum;
						return sprintf("总数 : %s <br> 占位 : %s <br> 付定金 : %s <br> 已付款 : %s <br> 确认提交 : %s <br> %s", $nums['total'], $nums[1] , $nums[2] , $nums[3], $nums[4],$a);
	                }
            	],
	            [
                	'class' => 'yii\grid\ActionColumn',
                	'header' => '操 作',
                	'template' =>"{view} {update}"
            	],
	            //['class' => 'yii\grid\ActionColumn'],
	        ],
	    ]); ?>
	<?php Pjax::end(); ?>
</div>


<div class="modal fade nums-modal"   role="dialog" aria-labelledby="myLargeModalLabel">
  <div class="modal-dialog " role="document" style="width:740px;">
      <div class="modal-content">
	 		<!-- 嵌入内容 --> 
	  </div>
  </div>
</div>


<?php app\components\JsBlock::begin() ?>
<script type="text/javascript">
// 清除模态框缓存
$(".nums-modal").on("hidden.bs.modal", function() {
	$(this).removeData("bs.modal");
});


</script>
<?php app\components\JsBlock::end() ?>   
